﻿using System;
using System.IO;
using System.Windows.Forms;

namespace AutoKillThing
{
    public partial class FrmInput : Form
    {
        public string answer;

        public FrmInput()
        {
            InitializeComponent();
        }

        private void CmdOk_Click(object sender, EventArgs e)
        {
            string checkString = TxtAnswer.Text.Trim();
            if (checkString.Length > 0)
            {
                answer = checkString;
            }
            this.Close();
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmdBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog()
            {
                AddExtension = true,
                Filter = "Executable (*.exe)|*.exe|Winbatch (*.wbt;*.wbc)|*.wbt;*.wbc",
                CheckFileExists = true,
                CheckPathExists = true,
                Multiselect = false,
                Title = "Please select file to add"

            };

            dlg.ShowDialog();

            if (dlg.FileName.Length > 0)
            {
                TxtAnswer.Text = Path.GetFileName(dlg.FileName);
            }

        }

        private void TxtAnswer_TextChanged(object sender, EventArgs e)
        {
            if (TxtAnswer.Text.Trim().Length > 0)
            {
                CmdOk.Enabled = true;
                return;
            }
            CmdOk.Enabled = false;
        }
    }
}
